/***
 * @Description:
 * @Author: LI Yihong
 * @Email: liyh@jihua.ac.cn
 * @Date: 2024-10-22 11:31:09
 * @LastEditTime: 2024-10-22 11:31:10
 * @LastEditors: LI Yihong
 * @FilePath: \STM32F407_Board\applications\thread_ctrl.h
 */
#pragma once
#include "led/led.hpp"
#include "keyPress/keyPress.hpp"
#include "watchdog/watchDog.hpp"
#include "I2C/24C02.hpp"
#include "I2C/MCP4728.hpp"
#include <string>
#include <vector>
#include <memory>
#include "cxx_thread.h"
#include "cxx_semaphore.h"

using namespace std;
using namespace rtthread;

class ThreadCtrl
{
private:
    // thread
    unique_ptr<LED> ledThread;
    unique_ptr<KeyPress> keyThread;
    unique_ptr<WatchDog> watchdogThread;
    unique_ptr<EEPROM_24C02> EEPROM_24C02Thread;
    unique_ptr<MCP4728> MCP4728Thread;

    void threadInit();
    void threadStart();
    void semInit();
    void mailInit();
    void queueInit();

public:
    static ThreadCtrl &getInstance();

    // semaphore

    // mailBox
    shared_ptr<Mail<vector<string>, 10>> cmdMail;

    // message queue

private:
    ThreadCtrl();
    ~ThreadCtrl();
    ThreadCtrl(const ThreadCtrl &) = delete;
    ThreadCtrl &operator=(const ThreadCtrl &) = delete;
};
